<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../react18/react.development.js"></script>
  <script src="../react18/react-dom.development.js"></script>
  <script src="../react18/babel.min.js"></script>
</head>

<body>
  <div id="app"></div>
  <script type="text/babel">

    class App extends React.Component{
      state = {
        isLove:true,
        count:0
      }

      render(){
        const{isLove,count}=this.state
        return (

            <div>
               <button onClick={this.handle}>哈哈哈</button> 
               <h1>{isLove?'条条的啊呜':'papapiu'}</h1>
               <h2>{count}</h2>
            </div>
        )
      }
      //给原型上写事件函数
      handle(){
        console.log(this)//这个this还是指向undefined
        this.state.isLove = !this.state.isLove;
        ++count
      }



    }

    const root = ReactDOM.createRoot(document.getElementById('app'));
    root.render(<App/>)






    // 案例:确实是我们做了一件事情(调用了fn),shijian才调用,但是根据下边的案例看,shijian的调用方式是默认调用,this指向undefined(严格模式下)
    /* function shijian(){

    }
  
    function fn(){
      shijian();
    }
    fn() */
  


  </script>
</body>

</html>